<!--编辑读者信息-->
<html>
<head>
    <meta charset="utf-8">
    <!--<meta http-equiv="X-UA-Compatible" content="IE=edge">-->
    <!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
    <title>编辑读者信息《 ${readerInfo.readerId}》</title>
    <!--<link rel="stylesheet" href="css/bootstrap.min.css">-->
    <!--<script src="js/jquery-3.3.1.js"></script>-->
    <!--<script src="js/bootstrap.min.js" ></script>-->
    <!--<script src="js/getParameter.js"></script>-->
    <script>

        $(function (){
            // var parameter = getParameter("reader_id");
            var parameter = $.cookie("reader_id");
            $.removeCookie("reader_id");
            //alert(parameter);

            $.ajax({
                type:"post",
                dataType:"json",
                url:"user/adminSelectReader",
                data:{"readerId":parameter},
                success:function (data){
                    //alert(data.reader_id)
                        $("#reader_id").val(data.reader_id);
                        $("#name").val(data.name);
                        $("#sex").val(data.sex);
                        $("#birth").val(format(data.birth));
                        $("#address").val(data.address);
                        $("#telcode").val(data.telcode);
                }
            })




            $("#update_reader").click(function () {
                    $.ajax({
                        type:"post",
                        dataType:"json",
                        url:"user/adminUpdateReader",
                        data:$("#readeredit").serialize(),
                        success:function (data){
                            if (data) {
                                alert("修改成功");
                                $("#middle").load("admin_readers.html");
                            }else {
                                alert("修改失败");
                            }
                        }
                    })
                return false;
            })
        })


        function format(object) {
            var year = new Date(object).getFullYear(); //获取完整的年份(4位,1970-????)
            var month = new Date(object).getMonth() + 1; //获取当前月份(0-11,0代表1月)
            var day = new Date(object).getDate(); //获取当前日(1-31)
            if (month < 10) {
                month = "0" + month;
            }
            if (day < 10) {
                day = "0" + day;
            }
            var dateString =  year + "-" + month + "-" + day;
            return dateString;

        }
    </script>

    <style>
        body{
            background-color: rgb(240,242,245);
        }
    </style>

</head>
<body>

<div class="col-xs-6 col-md-offset-3" style="position: relative;top: 10%">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">编辑读者信息《 ${readerInfo.readerId}》</h3>
        </div>
        <div class="panel-body">
            <form  method="post" id="readeredit" >

                <div class="input-group">
                    <span  class="input-group-addon">读者证号</span>
                    <input readonly="readonly" type="text" class="form-control" name="reader_id" id="reader_id" />
                </div>
                <div class="input-group">
                    <span class="input-group-addon">姓名</span>
                    <input type="text" class="form-control" name="name" id="name"  >
                </div>
                <div class="input-group">
                    <span  class="input-group-addon">性别</span>
                    <input type="text" class="form-control" name="sex" id="sex"   >
                </div>
                <div class="input-group">
                    <span class="input-group-addon">生日</span>
                    <input type="date" class="form-control" name="birth" id="birth"  >
                </div>
                <div class="input-group">
                    <span  class="input-group-addon">地址</span>
                    <input type="text" class="form-control" name="address" id="address"  >
                </div>
                <div class="input-group">
                    <span class="input-group-addon">电话</span>
                    <input type="text" class="form-control" name="telcode" id="telcode"  >
                </div>
                <input id="update_reader" type="submit" value="确定" class="btn btn-success btn-sm" class="text-left">
                <script>


                </script>
            </form>
        </div>
    </div>

</div>

</body>
</html>
